//
//  ViewController.swift
//  TAP-COUNTER
//
//  Created by 赵国腾的MacBook Pro on 2017/1/8.
//  Copyright © 2017年 赵国腾的MacBook Pro. All rights reserved.
//

import UIKit

class ViewController: UIViewController {

    @IBOutlet weak var numberLabel: UILabel!
    
    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view, typically from a nib.
    }

    
    // 按钮点击
    @IBAction func buttonClick(button: UIButton) {
        
        if let labelText = numberLabel.text {
            
            let numberFormatter =  NumberFormatter()
            numberFormatter.numberStyle = .currency
            
            if let number = numberFormatter.number(from: labelText) {
                
                var numberInt = number.intValue
                numberInt += 99
                
                let numberString = numberFormatter.string(from: NSNumber(integerLiteral: numberInt))
                
                numberLabel.text = numberString
                
            }
        }
        
    }
    
    // 重置
    @IBAction func reset() {
        
        numberLabel.text = "$0"
    }
}

